package cn.pconline.autoclub.entity;

import java.util.Date;
import org.apache.commons.lang.StringUtils;
import org.gelivable.dao.Column;
import org.gelivable.dao.Entity;
import org.gelivable.dao.Id;
import org.gelivable.dao.Label;

/**
 *
 * @author liuxulin
 */
@Entity(tableName = "ac_gift")
public class Gift {

    public static final int STATUS_UP = 1; //上架
    public static final int STATUS_DOWN = 0;//下架
    public static final int STATUS_DELETE = -1;//删除
    public static final int STATUS_GOLD_OK = 0;//消费金币成功
    public static final int STATUS_GOLD_FAIL = -1;//消费金币失败
    public static final int STATUS_GOLD_ERROR = -2;//消费金币出错
    @Id
    @Column(name = "gift_id")
    private long giftId;
    @Label(value = "礼品名称")
    @Column(name = "name")
    private String name;
    @Label(value = "礼品图片")
    @Column(name = "url")
    private String giftUrl;
    @Label(value = "总数量")
    @Column(name = "total")
    private int total;
    @Label(value = "金币")
    @Column(name = "gold")
    private long gold;
    @Label(value = "当前库存")
    @Column(name = "cur_num")
    private int curNum;
    @Label(value = "创建时间")
    @Column(name = "create_at")
    private Date createAt;
    @Label(value = "创建人")
    @Column(name = "create_by")
    private long createBy;
    @Label(value = "更新人")
    @Column(name = "update_by")
    private long updateBy;
    @Label(value = "更新时间")
    @Column(name = "update_at")
    private Date updateAt;
    @Label(value = "状态")
    @Column(name = "status")
    private int status;
    @Label(value = "序号")
    @Column(name = "seq")
    private int seq;
    @Label(value = "链接")
    private String link;

    public long getGiftId() {
        return giftId;
    }

    public String getName() {
        return name;
    }

    public String getGiftUrl() {
        return giftUrl;
    }

    public int getTotal() {
        return total;
    }

    public int getCurNum() {
        return curNum;
    }

    public Date getCreateAt() {
        return createAt;
    }

    public long getCreateBy() {
        return createBy;
    }

    public Date getUpdateAt() {
        return updateAt;
    }

    public void setGiftId(long giftId) {
        this.giftId = giftId;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setGiftUrl(String giftUrl) {
        this.giftUrl = giftUrl;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public void setCurNum(int curNum) {
        this.curNum = curNum;
    }

    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    public void setCreateBy(long createBy) {
        this.createBy = createBy;
    }

    public void setUpdateAt(Date updateAt) {
        this.updateAt = updateAt;
    }

    public long getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(long updateBy) {
        this.updateBy = updateBy;
    }

    public long getGold() {
        return gold;
    }

    public void setGold(long gold) {
        this.gold = gold;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getSeq() {
        return seq;
    }

    public void setSeq(int seq) {
        this.seq = seq;
    }

    private String convertImgage(String size) {
        String img = getGiftUrl();
        if (StringUtils.isBlank(img)) {
            return img;
        }
        if (img.indexOf("_170x170") > 0) {
            return img.replace("_170x170", "_" + size);
        }
        return img;
    }

    public String getGiftUrl60x60() {
        if (StringUtils.isNotBlank(giftUrl)) {
            return convertImgage("60x60");
        }
        return giftUrl;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }
}
